﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Miris.HumanMilkAnalyser.DataModel;
using Miris.HumanMilkAnalyser.Service;
using Miris.HumanMilkAnalyser.Service.Shared;
using Miris.HumanMilkAnalyser.WPF.Model;

namespace Miris.HumanMilkAnalyser.WPF.ViewModel.TestItemViewModel
{
    public class TestItemFatViewModel : TestItemSingleViewModel
    {
        /// <summary>
        /// Initializes a new instance of the FatTestItemViewModel class.
        /// </summary>
        public TestItemFatViewModel(IDataService dataService, IList<AnalysisItem> analysisItemList, MilkStage milkStage)
            : base(dataService, analysisItemList, milkStage) { }

        protected override void InitializeParameters()
        {
            base.InitializeParameters();

            TestItemName = AnalysisItemDefinition.FatItemName;
            SetAnalysisItem();
        }

        /// <summary>
        /// Set RangeStartValue & RangeEndValue based on CurrentMilkStage.
        /// </summary>
        protected override void SetTestResultRangeValue()
        {
            if (CurrentMilkStage == MilkStage.Unmature)
            {
                //RangeStartValue = 2.47;
                //RangeEndValue = 3.18;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatUnmatureMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatUnmatureMilkRangeEndValue);
            }
            else if (CurrentMilkStage == MilkStage.Transitional)
            {
                //RangeStartValue = 2.73;
                //RangeEndValue = 5.18;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatTransitionalMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatTransitionalMilkRangeEndValue);
            }
            else if (CurrentMilkStage == MilkStage.Mature)
            {
                //RangeStartValue = 1.34;
                //RangeEndValue = 8.29;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatMatureMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatMatureMilkRangeEndValue);
            }
        }

        /// <summary>
        /// Set MinValue & MaxValue based on CurrentMilkStage.
        /// </summary>
        protected override void SetTestResultMinMaxValue()
        {
            base.SetTestResultMinMaxValue();

            //MaxValue = CurrentMilkStage == MilkStage.Unmature ? 5 : 10;

            if (CurrentMilkStage == MilkStage.Unmature)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatUnmatureMilkMaxValue);
            }
            else if (CurrentMilkStage == MilkStage.Transitional)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatTransitionalMilkMaxValue);
            }
            else if (CurrentMilkStage == MilkStage.Mature)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.FatMatureMilkMaxValue);
            }
        }
    }
}
